
const TokenKey = 'token'
//token
export function getToken() {
  return localStorage.getItem(TokenKey)
}
export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
}
export function removeToken() {
  return localStorage.removeItem(TokenKey)
}
//用户名
export function setName(name) {
  return localStorage.setItem("UserName", name)
}
export function getName() {
  return localStorage.getItem("UserName")
}
export function removeName() {
  return localStorage.removeItem("UserName")
}
//头像
export function setAvatar(name) {
  return localStorage.setItem("Avatar", name)
}
export function getAvatar() {
  return localStorage.getItem("Avatar")
}
export function removeAvatar() {
  return localStorage.removeItem("Avatar")
}
//用户信息
export function setUserInfo(userInfo) {
  return localStorage.setItem("UserInfo", JSON.stringify(userInfo))
}
export function getUserInfo() {
  let obj = localStorage.getItem("UserInfo")
  try{
    obj = JSON.parse(obj)
  }catch (e) {
    obj ={}
  }
 return obj
}
export function removeUserInfo() {
  return localStorage.removeItem("UserInfo")
}
//清除所有
export function clearLocalStorage() {
  return localStorage.clear()
}